package cn.life.common.support;

import cn.life.common.entity.model.MyUserInfo;
import cn.life.common.entity.model.MyCommon;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Description:    Session管理
 *
 * @Author 李佳明
 * @Date 2018/7/17 0017 下午 3:47
 */
public class SessionManager {

    public void createSession(HttpServletRequest request, HttpServletResponse response, MyUserInfo myUserInfo) throws IOException {
        //使用request对象的getSession()获取session，如果session不存在则创建一个
        HttpSession session = request.getSession();
        //将数据存储到session中
        session.setAttribute(MyCommon.MY_SESSION_KEY, myUserInfo);
    }
}
